﻿// ReSharper disable CppClangTidyModernizeUseNodiscard
#pragma once
#include "Material.h"
#include "Texture2D.h"
#include "Path.h"
#include "ShaderProgram.h"

class FTranspareMaterial final
	: public FMaterial
{
private:

	std::shared_ptr<FTexture2D> Texture;
public:

	virtual bool Init() override
	{
		if (!FMaterial::Init())
		{
			return false;
		}

		Shader->SetLightingModel(ELightingModel::None);

		Texture = FTextureBuild{}.Build(FPath::BuildImgPath("blending_transparent_window.png"));

		Shader->Use();

		Shader->SetInt("texture1", 0);

		return true;
	}

	virtual void Use() override
	{
		FMaterial::Use();

		Texture->BindTextureUnit(0);
	}

	const std::string& GetFsSrcCode() const override
	{
		static std::string CodeStr = R"(
			#version 410 core
			out vec4 FragColor;
			
			in vec2 TexCoord;
			
			uniform sampler2D texture1;
			
			void main()
			{
			     FragColor = texture(texture1, TexCoord);
			}
		)";

		return CodeStr;
	}

	const std::string& GetVsSrcCode() const override
	{
		static std::string CodeStr = R"(

			#version 410 core 
			
			layout (location = 0) in vec3 aPos;
			layout (location = 1) in vec3 aNormal;
			layout (location = 2) in vec2 aTexCoord;
			
			out vec2 TexCoord;
			
			uniform mat4 model;
			uniform mat4 view;
			uniform mat4 projection;
			
			
			void main()
			{
			    gl_Position = projection *  view * model * vec4(aPos, 1.0);
			    TexCoord = vec2(aTexCoord.x, aTexCoord.y);
			}

		)";

		return CodeStr;
	}
};

